package cn.rubintry.animatorutils

import android.os.Build
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.animation.LinearInterpolator
import android.widget.TextView
import androidx.annotation.RequiresApi
import cn.rubintry.animate.AnimateUtils
import cn.rubintry.animate.core.param.AnimatorParam
import cn.rubintry.animate.core.param.AnimatorType
import cn.rubintry.animate.core.param.Value

class MultiOnSingleActivity : AppCompatActivity() {
    private var tvText: TextView ?= null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_multi_on_single)
        tvText = findViewById(R.id.tv_text)
        val value = Value()
        value.put(AnimatorType.TRANSLATION , AnimatorParam.OFFSET_X , 500)
        value.put(AnimatorType.TRANSLATION , AnimatorParam.OFFSET_Y , 500)
        value.put(AnimatorType.TRANSLATION , AnimatorParam.REVERSE , true)
        value.put(AnimatorType.SCALE , AnimatorParam.FROM_SCALE , 1)
        value.put(AnimatorType.SCALE , AnimatorParam.TO_SCALE , 5)
        value.put(AnimatorType.SCALE , AnimatorParam.REVERSE , true)
        value.put(AnimatorType.ROTATE , AnimatorParam.ANGLE , 90)
        value.put(AnimatorType.ROTATE , AnimatorParam.REVERSE , true)
        AnimateUtils.with(tvText)
            .multiAnimation()
            .enableTranslation()
            .enableRotate()
            .load(value)
            .setDuration(200)
            .setInterpolator(LinearInterpolator())
            .enableLoop(true)
            .start()
        AnimateUtils.with(tvText)
            .alpha(0f , 1f , true)
            .enableLoop(true)
            .start()

        AnimateUtils.with(tvText)
            .scale(0f , 1f , true)
            .enableLoop(true)
            .start()
        
    }
}